API Documentation
Public Member Functions | List of all members
nkTasks::Task Class Referenceabstract

A task, job that can be submitted to a nkTasks::Thread. More...

Inheritance diagram for nkTasks::Task:
nkAstraeus::lua::nkTasksWrap::LuaTask nkGraphics::ResourceTask nkTasks::LambdaTask

Public Member Functions

 Task ()
 
virtual ~Task ()
 
ThreadgetParentThread () const
 
TASK_RESULT getWorkResult () const
 
void setParentThread (Thread *thread)
 
void setWorkResult (TASK_RESULT result)
 
virtual TASK_RESULT onWork ()=0
 
virtual void onWorkDone ()=0
 
virtual void onSuccess ()=0
 
virtual void onFail ()=0
 
virtual void onAbort ()=0
 

Detailed Description

A task, job that can be submitted to a nkTasks::Thread.

Any external code can implement this class, enabling it to be processed by this component.

Constructor & Destructor Documentation

◆ Task()

nkTasks::Task::Task ( )

Constructor.

◆ ~Task()

virtual nkTasks::Task::~Task ( )
virtual

Destructor.

Member Function Documentation

◆ getParentThread()

Thread* nkTasks::Task::getParentThread ( ) const
Returns
The thread currently processing this task.

◆ getWorkResult()

TASK_RESULT nkTasks::Task::getWorkResult ( ) const
Returns
Current task result state.

◆ setParentThread()

void nkTasks::Task::setParentThread ( Thread thread)

Sets the parent thread for the task.

Parameters
threadThe thread that will be marked as a parent for this task.
Remarks
In theory, this function should not be called by external code.

◆ setWorkResult()

void nkTasks::Task::setWorkResult ( TASK_RESULT  result)

Sets the current work result for the task.

Parameters
resultThe task work result to attach.
Remarks
In theory, this function should not be called by external code.

◆ onWork()

virtual TASK_RESULT nkTasks::Task::onWork ( )
pure virtual

Callback for the work that the task needs to do. This will be called in thread task has been assigned to.

Returns
Such a function should return the work result after processing.

Implemented in nkGraphics::ResourceTask, and nkTasks::LambdaTask.

◆ onWorkDone()

virtual void nkTasks::Task::onWorkDone ( )
pure virtual

Callback called after onWork() has been done. This will be called in thread task has been assigned to.

Implemented in nkGraphics::ResourceTask, and nkTasks::LambdaTask.

◆ onSuccess()

virtual void nkTasks::Task::onSuccess ( )
pure virtual

Callback for work that has returned a TASK_RESULT::SUCCESS code. Only called if task has been submitted to a scheduler. It will be called from the thread owning the scheduler.

Implemented in nkGraphics::ResourceTask, and nkTasks::LambdaTask.

◆ onFail()

virtual void nkTasks::Task::onFail ( )
pure virtual

Callback for work that has returned a TASK_RESULT::FAIL code. Only called if task has been submitted to a scheduler. It will be called from the thread owning the scheduler.

Implemented in nkGraphics::ResourceTask, and nkTasks::LambdaTask.

◆ onAbort()

virtual void nkTasks::Task::onAbort ( )
pure virtual

Callback for work that has returned a TASK_RESULT::ABORT code. Only called if task has been submitted to a scheduler. It will be called from the thread owning the scheduler.

Implemented in nkGraphics::ResourceTask, and nkTasks::LambdaTask.


The documentation for this class was generated from the following file: